home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7367 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1009 b 

  1. Path: newshost.cyberramp.net!news
  2. From: sinan@cyberramp.net (John Noland)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do I modify a character string that's declared as an array of char?
  5. Date: 25 Feb 1996 22:34:43 GMT
  6. Organization: Prose Software
  7. Distribution: world
  8. Message-ID: <4gqo63$2pr@newshost.cyberramp.net>
  9. References: <4gj2nl$840@mirzam.usc.edu>
  10. NNTP-Posting-Host: ramp3-4.cyberramp.net
  11. X-Newsreader: WinVN 0.99.5
  12.  
  13. In article <4gj2nl$840@mirzam.usc.edu>, awawda@mirzam.usc.edu says...
  14. >
  15. >How do I write a function that can modify a string that was declared
  16. >as an array of characters?
  17. >
  18. >for example:
  19. >
  20. >myfunction(char **s)
  21.                  ^^
  22.         You only need one of these
  23.  
  24. >{
  25. >        // modify string s
  26. >}
  27. >
  28. >main()
  29. >{
  30. >   char mydata[50];
  31. >
  32. >   strcpy(mydata,"test string");
  33. >   myfunction(&mydata);
  34.                ^ 
  35. Dereferencing mydata isn't necessary. mydata is a pointer to the first 
  36. character of your array, so what you're really doing is passing a pointer
  37. to that pointer.
  38.            
  39. -John
  40.  
  41.